import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/admin/login',
    method: 'post',
    data: {
      userId: data.userId,
      userPwd: data.password
    }
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { userId: token }
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function getAllStu() {
  return request({
    url: '/user/usertype',
    method: 'get',
    params: {
      userType: 0
    }
  })
}

export function getAllTea() {
  return request({
    url: '/user/usertype',
    method: 'get',
    params: {
      userType: 1
    }
  })
}

export function resetPwd(userId) {
  return request({
    url: '/user/reset',
    method: 'post',
    data: {
      userId: userId
    }
  })
}

export function updatePwd(userId, userPwd) {
  return request({
    url: '/user/pwd',
    method: 'put',
    params: {
      userId: userId,
      userPwd: userPwd
    }
  })
}

export function deexport() {
  return request({
    url: '/user/Excel',
    method: 'get'
  })
}

export function addUser(user) {
  return request({
    url: '/user/add',
    method: 'post',
    data: {
      userId: user.username,
      userPwd: user.password,
      userType: 1
    }
  })
}

export function search(search) {
  return request({
    url: '/user/search',
    method: 'get',
    params: {
      userId: search.userId,
      userName: search.userName
    }
  })
}
